#include <bits/stdc++.h>
using namespace std;
#define int long long

void solve() {
    int x, y;
    cin >> x >> y;
    if(x == y) {
        cout << x << ' ' << y << endl;
    }
    cout << (1 << 30) - max(x, y) << endl;
}

signed main() {
    int t = 1;
    cin >> t;
    while(t--) solve();
    return 0;
}